<%@ page import="com.biz.conf.Global" %>
<%@ page import="com.biz.model.Singleton.ZkNode" %>
<%@ include file="/jsp/taglib.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>信息编辑窗体</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <%--<link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">--%>
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <link href="${pageContext.request.contextPath}/resources/plugins/h+/css/plugins/jsTree/style.min.css" rel="stylesheet">

<style>
    .fileInputContainer{
        width: 150px;
        background-size: 100% 100%;
        height: 150px;
        background-repeat: no-repeat;
    }
    .fileInput{
        position: absolute;
        top:30%;
        left:30%;
    }.upload_pic {
         height: 70px;
         width:70px;
         position: relative;
         cursor: pointer;
         color: #ccbe9e;
         background: #fff;
         overflow: hidden;
         display: inline-block;
         *display: inline;
         *zoom: 1;
     }
    .upload_pic input {
        position: absolute;
        height:100%;
        width:100%;
        right: 0;
        top: 0;
        opacity: 0;
        filter: alpha(opacity=0);
        cursor: pointer
    }
    .upload_pic:hover {
        color: #ccbe9e;
        background: #fff;
        text-decoration: none
    }
</style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>表单验证</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm" onsubmit="return  false">
                        <input type="hidden" value="${type}" name="pshop.type">
                        <input type="hidden" value="${sid}" name="pshop.sid">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">门店logo：</label>
                            <div class="col-sm-8">
                                <%--<div class="fileInputContainer" id="f03" align="center">--%>
                                <input type="hidden" id="picid2" name="pshop.logo_url">
                                <%--&lt;%&ndash;<input type="file" class="fileInput" id="upfile2" name="fileToUpload" onChange="uploadFileEidt('upfile2','f03');" />&ndash;%&gt;--%>
                                <%--</div>--%>
                                <div class="dtupload">
                                    <a href="javascript:;" class="upload_pic" style="height:80px;"><input type="file" name="fileToUpload" id="upfile2" onChange="uploadFileEidt('upfile2','f03');">
                                        <img  id="f03" src="${pageContext.request.contextPath}/resources/image/logopic1.png" width="100%"  height="100%"/>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">门店名称：</label>
                            <div class="col-sm-8">
                                <input id="business_name" name="pshop.business_name" class="form-control" type="text">
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>门店名不得含有区域地址信息（如，北京市XXX公司）</span>
                            </div>
                        </div>
                        <div class="form-group" id="loginDiv">
                            <label class="col-sm-3 control-label">门店账号：</label>
                            <div class="col-sm-4">
                                <input id="login_name" name="pshop.login_name" placeholder="账号" class="form-control" type="text">
                            </div>
                            <%--<label class="col-sm-3 control-label">门店登陆密码：</label>--%>
                            <div class="col-sm-4">
                                <input id="pwd" name="pshop.pwd" class="form-control" placeholder="请输入门店密码" type="password">
                            </div>
                        </div>



                        <div class="form-group">
                            <label class="col-sm-3 control-label">类目：</label>
                            <div class="col-sm-4">
                                <select id="category_first_select" data-placeholder="选择类目..." class="chosen-select" name="pshop.category_first"    onchange="ajaxCategorySecond(this)"   class="form-control">
                                </select>
                            </div>
                            <div class="col-sm-4">
                                <select id="category_second_select" data-placeholder="选择类目..." class="chosen-select"  name="pshop.category_second"     class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">所属区域：</label>
                            <div class="col-sm-4">
                                <select id="agent_province" data-placeholder="选择省份..." class="chosen-select"  value="${pshop.province}"  onchange="loadCity(this.value)"  name="pshop.province" class="form-control">
                                </select>
                            </div>
                            <div class="col-sm-2">
                                <select id="agent_city"  data-placeholder="选择城市..." class="chosen-select"   value="${pshop.city}" name="pshop.city" class="form-control" onchange="loadArea(this.value)">
                                </select>
                            </div>
                            <div class="col-sm-2">
                                <select id="agent_area"  data-placeholder="选择区..." class="chosen-select"   value="${pshop.district}" name="pshop.district" class="form-control" onchange="loadDis(this.value)">
                                </select>
                            </div>

                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">所属商圈：</label>
                            <div class="col-sm-8">
                                <select id="agent_dis" data-placeholder="选择省份..." class="chosen-select"  value="${pshop.dis}"    name="pshop.dis" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">所属商户：</label>
                            <div class="col-sm-8">
                                <select id="agent_brand" data-placeholder="所属商户..." class="chosen-select"  value="${pshop.brand_code}"    name="pshop.brand_code" class="form-control">

                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">仓库选择：</label>
                            <div class="col-sm-8">
                                <input type="hidden" name="pshop.stockName" id="stockName">
                                <select id="agent_stock" data-placeholder="所属仓库..." class="chosen-select"  value="${pshop.stockId}"    name="pshop.stockId" class="form-control">

                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">门店经纬度：</label>
                            <div class="col-sm-8">
                                <%--<div id="allmap">地图查看</div>--%>
                                <input id="longitude" name="pshop.longitude" class="form-control" type="text" readonly onclick="showMap()">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">详细地址：</label>
                            <div class="col-sm-8">
                                <input id="address" name="pshop.address" class="form-control" type="text">
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>门店所在的详细街道地址（不要填写省市信息）</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">电话：</label>
                            <div class="col-sm-8">
                                <input id="telephone" name="pshop.telephone" class="form-control" type="text">
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>固定电话需加区号；区号、分机号均用“-”连接</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序：</label>
                            <div class="col-sm-8">
                                <input id="sort" name="pshop.sort" class="form-control" type="text" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">人均价格：</label>
                            <div class="col-sm-8">
                                <input id="avg_price" name="pshop.avg_price" class="form-control" type="text" >
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>（选填）大于零的整数，须如实填写，默认单位为人民币</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">营业时间：</label>
                            <div class="col-sm-8">
                                <input id="open_time" name="pshop.open_time" class="form-control" type="text" >
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>（选填）如，10:00-21:00</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">推荐品：</label>
                            <div class="col-sm-8">
                                <input id="recommend" name="pshop.recommend" class="form-control"  >
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>(选填)如，推荐菜，推荐景点，推荐房间</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">特色服务：</label>
                            <div class="col-sm-8">
                                <input id="special" name="pshop.special" class="form-control"  >
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>(选填)如，免费停车，WiFi</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">简介：</label>
                            <div class="col-sm-8">
                                <input id="introduction" name="pshop.introduction" class="form-control"  >
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>(选填)对商户或门店的简要介绍</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">店小翼门店code：</label>
                            <div class="col-sm-8">
                                <input id="dxy_code" name="pshop.dxy_code" class="form-control"  >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">店小翼店长code：</label>
                            <div class="col-sm-8">
                                <input id="dxy_person_code" name="pshop.dxy_person_code" class="form-control"  >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">初始收银金额(分)：</label>
                            <div class="col-sm-8">
                                <input id="initial_money" name="pshop.initial_money" class="form-control"  >
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>门店app端收银界面默认金额,单位为 ：分,默认为0</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否固定收银金额：</label>
                            <div class="col-sm-3">
                                <div class="switch">
                                    <div class="onoffswitch">
                                        <input type="checkbox" class="onoffswitch-checkbox" id="money_fixed" name="pshop.money_fixed">
                                        <label class="onoffswitch-label" for="money_fixed">
                                            <span class="onoffswitch-inner"></span>
                                            <span class="onoffswitch-switch"></span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否90线下体验店：</label>
                            <div class="col-sm-3">
                                <div class="switch">
                                    <div class="onoffswitch">
                                        <input type="checkbox" class="onoffswitch-checkbox" id="is_90" name="pshop.is_90">
                                        <label class="onoffswitch-label" for="is_90">
                                            <span class="onoffswitch-inner"></span>
                                            <span class="onoffswitch-switch"></span>
                                        </label>
                                    </div>
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>根据品牌属性展示，门店无法修改</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary"  onclick="doSave()">提交</button>
                                <button id="btn_close"  class="btn btn-primary" type="button">关闭</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/content.min.js?v=1.0.0"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/validate/messages_zh.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/demo/form-validate-demo.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/layer2.4/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/ajaxfileupload.js"></script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/chosen/chosen.jquery.js"></script>
<script>
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
var picPath='<%=Global.getConfig("OSSURL")%>';
var proId="${prov}";
var cityId="${city}";
var sid="${sid}";
    var isLoad=0;
var category_first="${category_first}";
var category_second="${category_second}";
    $(function(){
//加载一级类目
        ajaxCategoryFirst();
    });


    //parent.layer.iframeAuto(index);
    //让层自适应iframe
    $('#add').on('click', function(){
        $('body').append('插入很多酱油。插入很多酱油。插入很多酱油。插入很多酱油。插入很多酱油。插入很多酱油。插入很多酱油。');

    });
    //给父页面传值
    $('#transmit').on('click', function(){

       // parent(".J_iframe").$("#spancc").text("5");
        alert(parent.$('#spancc').text());
        $(parent.window.frames["iframe8"].document).find("#spancc").html("我被改变了");
        $(parent.window.frames["iframe8"].document).find("#exampleTablePagination").bootstrapTable('refresh');
        //parent.$('#spancc').html('我被改变了');
        parent.layer.close(index);
    });

    //关闭iframe
    $('#btn_close').click(function(){
        parent.layer.close(index);
    });

    //上传头像
    function uploadFileEidt(obj,pic){
        $.ajaxFileUpload  ({
            url: '${pageContext.request.contextPath}/file/doUploadFile.ac',
            secureuri: false,
            fileElementId: obj,
            dataType: 'json',
            beforeSend: function() {
                //$("#loading").show();
            },
            complete: function() {
                //$("#loading").hide();
            },
            success: function(data, status) {

                var hi=picPath+data.path;
                $("#"+pic).attr("src",hi);
                $("#picid2").attr("value",data.picId);
            },
            error: function(data, status, e) {
                alert(e);
            }
        });
    }

    //加载一级类目
    function ajaxCategoryFirst()
    {
        $.ajax( {
            url:'${pageContext.request.contextPath}/shop/queryCategoryFirst.ac?guid='+new Date().getTime(),// 跳转到 action
            data:{},
            type:'post',
            cache:false,
//            dataType:'json',
            success:function(data) {
                data=eval("(" + data + ")");
                if (data.length>0)
            {
                var selected = '';
                for (var i=0;i<data.length;i++)
                {
                    var html = '<option value="'+data[i].category_code+'">'+data[i].category_name+'</option>';
                    $('#category_first_select').append(html);
                }
//                $('#category_first_select').chosen({
//                    no_results_text : "未找到此选项!",
//                    width:"100%"
//                });
                    $('#category_first_select').chosen({
                        no_results_text : "未找到此选项!",
                        width:"100%"
                    });
                if(category_first!=null&&category_first!=""){
                    $('#category_first_select').val(category_first);
                }
                $("#category_first_select").trigger("chosen:updated");
                    //加载二级类目
                    ajaxCategorySecond();
            }
            },
//            error : function() {
//                alert("操作失败！");
//            }
        });
    }

    //加载二级类目
    function ajaxCategorySecond()
    {
        var parent_code=$("#category_first_select").val();
        $('#category_second_select').html("");
        $.ajax( {
            url:'${pageContext.request.contextPath}/shop/queryCategoryByParent.ac?parent_code='+parent_code+'&guid='+new Date().getTime(),// 跳转到 action
            data:{},
            type:'post',
            cache:false,
//            dataType:'json',
            success:function(data) {
                data=eval("(" + data + ")");
                if (data.length>0)
                {
                    var selected = '';
                    for (var i=0;i<data.length;i++)
                    {
                        var html = '<option value="'+data[i].category_code+'">'+data[i].category_name+'</option>';
                        $(html).appendTo('#category_second_select');
                    }
                    $('#category_second_select').chosen({
                        no_results_text : "未找到此选项!",
                        width:"100%"
                    });
                    if(category_second!=null&&category_second!=""){
                        $('#category_second_select').val(category_second);
                    }
                    $("#category_second_select").trigger("chosen:updated");
                }
                //加载省份
                loadPr();
            },
        });
    }

    function loadPr()
    {
        $.ajax( {
            url:'${pageContext.request.contextPath}/area/getArea.ac',// 跳转到 action
            data:{},
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                areaData=data;
                var html='<option value="">请选择</option>';
                for(var i=0;i<data.pro.length;i++)
                {

                    html+='<option value="'+data.pro[i].id+'">'+data.pro[i].text+'</option>';

                }
                $("#agent_province").html(html);
                $("#agent_province").attr("disabled",true);
                $('#agent_province').chosen({
                    no_results_text : "未找到此选项!",
                    width:"100%"
                });

                if(proId!=null&&proId!=''&&proId!=undefined)
                {

                    $("#agent_province").val(proId);
                    $("#agent_province").trigger("chosen:updated");
                    loadCity(proId);
                }
            },
            error : function() {
                alert("加载代理商列表失败！");
            }
        });
    }
    function loadCity(id)
    {
        //  var id=obj.value;
        var data=areaData;
        var html='<option value="">请选择</option>';
        for(var i=0;i<data.city.length;i++)
        {
            if(data.city[i].pid==id)
            {
                html+='<option value="'+data.city[i].id+'">'+data.city[i].text+'</option>';
            }
        }
        $("#agent_city").html(html);
        $("#agent_city").attr("disabled",true);
        $('#agent_city').chosen({
            no_results_text : "未找到此选项!",
            width:"100%"
        });
        $("#agent_city").trigger("chosen:updated");
        if(cityId!=null&&cityId!=''&&cityId!=undefined&&id==proId)
        {
            $("#agent_city").val(cityId);
            $("#agent_city").trigger("chosen:updated");
            loadArea(cityId);
        }
    }

    function loadArea(id)
    {
        //  var id=obj.value;
        var data=areaData;
        var html='<option value="">请选择</option>';
        for(var i=0;i<data.area.length;i++)
        {
            if(data.area[i].pid==id)
            {
                html+='<option value="'+data.area[i].id+'">'+data.area[i].text+'</option>';
            }
        }
        $("#agent_area").html(html);
        $('#agent_area').chosen({
            no_results_text : "未找到此选项!",
            width:"100%"
        });
        $("#agent_area").trigger("chosen:updated");
//        if(cityId!=null&&cityId!=''&&cityId!=undefined&&id==proId)
//        {
//            $("#agent_city").val(cityId);
//            $("#agent_city").trigger("chosen:updated");
//        }
        $("#agent_area").trigger("chosen:updated");
        //加载商户
        loadBrand();
    }

    function loadDis(id){
        $.ajax( {
            url:'${pageContext.request.contextPath}/shop/queryDistrictByPcode.ac?area_code='+id,// 跳转到 action
            data:{},
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
//                areaData=data;
                var html='<option value="">请选择</option>';
                for(var i=0;i<data.length;i++)
                {
                    html+="<option value='"+data[i].district_code+"'>"+data[i].district_name+"</option>";
//                    $("<option value='"+data[i].district_code+"'>"+data[i].district_name+"</option>").appendTo("#agent_dis");

                }
                    $("#agent_dis").html(html);
                $("#agent_dis").trigger("chosen:updated");
                $('#agent_dis').chosen({
                    no_results_text : "未找到此选项!",
                    width:"100%"
                });
                //加载仓库
                loadStock();
            },
            error : function() {
                alert("加载商圈列表失败！");
            }
        });
    }

    //加载商户
    function loadBrand(){
        var identity_code="${identity_code}";
        $.ajax( {
            url:'${pageContext.request.contextPath}/shop/loadBrand.ac?identity_code='+identity_code,// 跳转到 action
            data:{},
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                var html='<option value="">请选择</option>';
                for(var i=0;i<data.length;i++)
                {

                    $("<option value='"+data[i].brand_code+"'>"+data[i].name+"</option>").appendTo("#agent_brand");

                }
//                $("#agent_province").html(html);
                $('#agent_brand').chosen({
                    no_results_text : "未找到此选项!",
                    width:"100%"
                });
                //
                loadDis('');
            },
            error : function() {
                alert("加载商圈列表失败！");
            }
        });
    }

    //打开地图
    function doOpenMapPop(){
        //自定页
        parent.layer.open({
            type: 2,
            shift:4,//动画类型
            moveType:1,
            maxmin: true,
            shadeClose: true, //开启遮罩关闭
            area: ['700px', '530px'],
            content: '${pageContext.request.contextPath}/jsp/common/select_map.jsp',
            success: function(layero, index){
                //layer.title("888888888", index);
                var datas={"firstname":"555555"};
//                    var body = layer.getChildFrame('body', index);
                //var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
//                    console.log(body.html()) //得到iframe页的body内容
            },
            cancel: function(index){
//                    alert(index);
                return true;
            }
        });
    }

    //保存
    function doSave(){
        var business_name=$("#business_name").val();
        var logo_url=$("#picid2").val();
        var agent_district=$("#agent_area").val();
        var address=$("#address").val();
        var telephone=$("#telephone").val();
        var sort=$("#sort").val();
        var dxy_code=$("#dxy_code").val();
        var dxy_person_code=$("#dxy_person_code").val();
        var initial_money=$("#initial_money").val();
        var login_name=$("#login_name").val();
        var pwd=$("#pwd").val();
        var stockName=$("#agent_stock").find("option:selected").text();
        $("#stockName").val(stockName);
        var longitude=$("#longitude").val();
    var flag=true;
    if(login_name==null||login_name==undefined||login_name==''){alert("请输入门店账号");flag= false;}
    if(pwd==null||pwd==undefined||pwd==''){alert("请输入门店密码");flag= false;}
    if(business_name==null||business_name==undefined||business_name==''){alert("请输入门店名称");flag= false;}
    if(logo_url==null||logo_url==undefined||logo_url==''){alert("请上传门店logo");flag= false;}
    if(agent_district==null||agent_district==undefined||agent_district==''){alert("请选择区");flag= false;}
    if(address==null||address==undefined||address==''){alert("请输入详细地址");flag= false;}
    if(longitude==null||longitude==undefined||longitude==''){alert("请选择经纬度");flag= false;}
    if(telephone==null||telephone==undefined||telephone==''){alert("请输入电话");flag= false;}
    if(sort==null||sort==undefined||sort==''){alert("请输入排序");flag= false;}
    if(dxy_code==null||dxy_code==undefined||dxy_code==''){alert("请输入店小翼门店code");flag= false;}
    if(dxy_person_code==null||dxy_person_code==undefined||dxy_person_code==''){alert("请输入店小翼店长code");flag= false;}
    if(initial_money==null||initial_money==undefined||initial_money==''){alert("请输入初始收银金额");flag= false;}


        if(flag){
            $.ajax( {
                url:'${pageContext.request.contextPath}/shop/doSave.ac',// 跳转到 action
                data:$("#signupForm").serialize(),
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data=="保存成功")
                    {
                        alert("操作成功！");
                        parent.layer.close(index);
//                        window.top.reload();
                    }else
                    {
                        alert(data);
                    }
                },
                error : function() {
                    alert("操作失败！");
                }
            });
        }
    }

    function loadStock(){
        $.ajax( {
            url:'${pageContext.request.contextPath}/shop/loadStock.ac',// 跳转到 action
            data:{},
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                var json = eval('(' + data + ')');
                var html='<option value="">请选择</option>';
                for(var i=0;i<json.length;i++)
                {
                    $("<option value='"+json[i].id+"'>"+json[i].text+"</option>").appendTo("#agent_stock");

                }
                $('#agent_stock').chosen({
                    no_results_text : "未找到此选项!",
                    width:"100%"
                });
                if(sid!=null&&sid!=""){
                    $("#loginDiv").hide();
                    if(isLoad==0) {
                        toEdit(sid);
                    }

                }else{
                    $("#loginDiv").show();
                }
            },
            error : function() {
                alert("加载仓库列表失败！");
            }
        });
    }
    function  showMap() {
        var longitude=$("#longitude").val();
        //自定页
        layer.open({
            type: 2,
            shift:4,//动画类型
            moveType:1,
            maxmin: true,
            shadeClose: true, //开启遮罩关闭
            area: ['800px', '500px'],
            title:'地图',
            <%--content: '${pageContext.request.contextPath}/shop/toShopEdit.ac',--%>
            content: '${pageContext.request.contextPath}/jsp/basic/shop/map.jsp?longitude='+longitude,
            success: function(layero, index){
                //layer.title("888888888", index);
                var datas={"firstname":"555555"};
            },
            cancel: function(index){
//                    alert(index);
                return true;
            }
        });
    }
    function  getLat(lng,lat) {
        $("#longitude").val(lng+','+lat);
    }

    function toEdit(sid){
        $.ajax( {
            url:'${pageContext.request.contextPath}/shop/toGetEdit.ac?sid='+sid,// 跳转到 action
            data:{},
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                $("#f03").attr("src","${OSSURL}"+data.path);
                $("#picid2").val(data.logo_url);
                $("#business_name").val(data.business_name);
                $("#login_name").val(data.loginName);
                $("#pwd").val(data.pwd);
                $("#agent_area").val(data.district);
                $("#agent_area").trigger("chosen:updated");
                $("#agent_brand").val(data.brand_code);
                $("#agent_brand").trigger("chosen:updated");
                $("#agent_stock").val(data.stockId);
                $("#agent_stock").trigger("chosen:updated");
                $("#longitude").val(data.longitude+','+data.latitude);
                $("#address").val(data.address);
                $("#telephone").val(data.telephone);
                $("#sort").val(data.sort);
                $("#avg_price").val(data.avg_price);
                $("#open_time").val(data.open_time);
                $("#recommend").val(data.recommend);
                $("#special").val(data.special);
                $("#introduction").val(data.introduction);
                $("#dxy_code").val(data.dxy_code);
                $("#dxy_person_code").val(data.dxy_person_code);
                $("#initial_money").val(data.initial_money);
                if(data.money_fixed=='1'){
                    $("#money_fixed").prop("checked",true)
                }else{
                    $("#money_fixed").prop("checked",false);
                }
                if(data.is_90=='1'){
                    $("#is_90").prop("checked",true)
                }else{
                    $("#is_90").prop("checked",false);
                }
                isLoad=1;
            },
        });
    }

</script>

</body>

</html>

